//
//  MainTableViewController.swift
//  iOSCases
//
//  Created by 申铭 on 2025/1/11.
//

import UIKit

enum CaseName: String {
    case AVAduioSession = "AVAduioSession"
}

class MainTableViewController: UITableViewController {
    
    var datas: Array<CaseName> = []

    override func viewDidLoad() {
        super.viewDidLoad()
        
        datas.append(.AVAduioSession)
        tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCell")
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return datas.count
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "UITableViewCell", for: indexPath)

        cell.accessoryType = .disclosureIndicator
        cell.textLabel?.text = datas[indexPath.row].rawValue

        return cell
    }

    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        
        let caseName = datas[indexPath.row]
        switch caseName {
        case .AVAduioSession:
            let vc = AVAduioSessionViewController.loadFromStoryboard(name: "Main", identifier: "AVAduioSessionViewController")
            self.navigationController?.pushViewController(vc, animated: true)
        }
    }
}
